#include "Includes.h"
#include "HL2Interface.h"

bool CheckKeys()
{
	static bool ESPActive = true;
	static bool AimbotActive = false;
	if (GetAsyncKeyState(VK_DIVIDE) & (1<<15))
	{
		ESPActive = !ESPActive;
		g_pESP.Set(ESPActive);
		return true;
	}
	else if (GetAsyncKeyState(VK_MULTIPLY) & (1<<15))
	{
		g_pEasyTrigger.Set(false);
		g_pKnifebot.Set(true);
		g_pNoSpread.SetMethod(false);
		g_pNoSpread.SetRecoil(true);
		AimbotActive = !AimbotActive;
		g_pSeedTrigger.Set(!AimbotActive);
		g_pAimbot.Set(AimbotActive);
		g_pNoSpread.Set(AimbotActive);
		return true;
	}
	else if (GetAsyncKeyState(VK_SUBTRACT) & (1<<15))
	{
		AimbotActive = false;
		g_pSeedTrigger.Set(false);
		g_pAimbot.Set(false);
		g_pNoSpread.SetMethod(true);
		g_pNoSpread.SetRecoil(false);
		g_pNoSpread.Set(true);
		g_pEasyTrigger.Set(true);
		g_pKnifebot.Set(true);
		return true;
	}
	else if (GetAsyncKeyState(VK_ADD) & (1<<15))
	{
		g_pSeedTrigger.Set(false);
		g_pEasyTrigger.Set(false);
		g_pAimbot.Set(true);
		g_pAimbot.SetLegitFov(true);
		g_pAimbot.SetLegitSpeed(true);
		g_pNoSpread.SetMethod(true);
		g_pNoSpread.SetRecoil(false);
		g_pNoSpread.SetRCS(false);
		g_pNoSpread.Set(true);
		g_pEasyTrigger.Set(false);
		return true;
	}
	return false;
}

void HackThread()
{
	g_pInterfaces.Start();
	//////////////////////////////////////////////////////////////////////////
	while (true)
	{
		if (CheckKeys())
		{
			Sleep(250);
		}
		Sleep(10);
	}
	//////////////////////////////////////////////////////////////////////////
	return;
}

BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPCVOID lpReserved)
{
	switch(dwReason)
	{
	case DLL_PROCESS_ATTACH:
		g_pInterfaces.hModuleBase = hInst;
		CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
		break;
	case DLL_PROCESS_DETACH:
		ExitProcess(0);
		break;
	}
	return TRUE;
}
